namespace mgp.ads {
    export class TtBannerAd extends WxBannerAd {

        protected _createBanner(id?: string) {
            let idx = Math.floor(Math.random() * this._info.ids.length);
            let crtId = id || this._info.ids[idx];
            let bannerObj = {
                adUnitId: crtId,
                style: this._getDefStyle()
            }
            if (this._info.refreshTime) {
                bannerObj['adIntervals'] = this._info.refreshTime
            }
            return wx.createBannerAd(bannerObj);
        }

        protected _getDefStyle(width?: number, height?: number) {
            let info = this._getSystemInfoSync();
            let offsetY = this._onIOS() && this._isLongPhone() ? 16 : 0;
            let defWidth = width || 288;
            let defHeight = height || 100;
            let style: IBannerStyle = {}
            style.left = (info.screenWidth - defWidth) / 2;
            style.top = info.screenHeight - defHeight - offsetY;
            return style;
        }

        protected _bannerReadyShow() {
        }

        protected _onBannerLoaded(res) {
            super._onBannerLoaded(res);
            this._bannerShow()
        }
    }
}